let arr=[
    {
        name:"01.txt",
        list:["aaa","bbb","ccc","ddd","eee"]
    },
    {
        name:"02.txt",
        list:["aaa","bbb","ccc","ddd","eee"]
    },
    {
        name:"03.txt",
        list:["aaa","bbb","ccc","ddd","eee"]
    },
    {
        name:"04.txt",
        list:["aaa","bbb","ccc","ddd","eee"]
    }
];

/* 
  1.require是什么？
    node模块系统的模块加载方法

  2.fs是什么？
    node环境提供的扩展模块(file system)文件系统模块 
    
*/

const fs=require("fs");
for(let i=0;i<arr.length;i++){
    let fileData=arr[i];
    let fileName=fileData.name;
    let fileList=fileData.list;
    // fs.appendFileSync(path,data)同步地将数据追加到文件中去,data需要字符串
    // let a="hello";
    // let obj={a:1000};
    // fs.appendFileSync(`./txt/${fileName}`,a);
    // fs.appendFileSync(`./txt/${fileName}`,obj);
    // fs.appendFileSync(`./txt/${fileName}`,fileList);
    // fileList.forEach(function(val,index){
    //     fs.appendFileSync(`./txt/${fileName}`,`${index+1}:${val}\n`);
    // });

    fs.appendFileSync(`./txt/${fileName}`,fileList.join("\n"));

}


